package com.web.expspringboot;

import com.web.expspringboot.entity.ProductSt;
import com.web.expspringboot.mapper.ProductMapper;
import com.web.expspringboot.mapper.UserMapper;
import com.web.expspringboot.service.PurchaseService;
import com.web.expspringboot.service.ProductService;
import com.web.expspringboot.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;

@SpringBootTest
public class SpringbootTestProductService {
    @Autowired
    UserMapper userMapper;

    @Autowired
    ProductMapper productMapper;

    @Autowired
    ProductService productService;

    @Autowired
    UserService userService;

    @Autowired
    PurchaseService messageService;

    @Test
    void generateProductsForTestUsers(){
        ProductSt product = new ProductSt();
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                product.setPublishTime(new Date());
                product.setProductTitle("Test Product " + i + "-" + j);
                product.setOwnerId(j + 1000);
                product.setProductIntro("test product, owner id: " + (j + 1000));
                product.setProductImgs("");
                product.setLocation("信息学部国软C4");
                product.setProductPrice(100);
                product.setStatus(1);
                productMapper.insertProduct(product);
            }
        }
    }
}
